
Image Tools Group
Part 2.

Nowadays there are two modifications of the GIF-files: GIF87a (GIF87) and GIF89a, developed 1987
and 1989 respectively. The ultimate is the GIF87a enhancement.
By 1987 the following features of the GIF87a modification were defined:
- the presence of several images included to single file (a frame is a separated image in a file);
- the possibility of positioning the image into the screen's logical area;
- the possibility of the interlaced image storage.
The GIF89a modification increased the opportunities of screening control, by addition of the
following parameters:
- the delay period (calculated in one hundredths of a second) before the next frame issue start;
- the waiting period before the user's move to next frame command;
- the transparent color selection;
- the addition of the annotation, that is not to be mapped when screening;
- text lines importation;
- selection of the recovery mode for the screen area covered by the image after the frame mapping completion;
- the inside GIF-file entries, specific for a certain application.
Basically the GIF89a differs from its precursor GIF87a by the ability to relay the set of the
graphic images on the run. The official documentation on GIF89a is dated on July, 31, 1990. Every
GIF89a standard deviation is considered illegal. Just because of this a viewer sometimes can not
recognize the file of the seeming to be widely known GIF-format.
The GIF89a format, which for the first time was supported only by Netscape 2.0 browser, made it
available to use animation in Web. You can create a sequence of images in GIF89a that are also
used as frames of the animation clip. The image animation is based on the one-by-one image
screening. This format also allows setting the screening time for each frame and the number of
iterations. Nowadays the GIF-animation is one of the most popular ways to create a simple
Web-pages animation, because all widely known browsers support this format. If the browser cannot
recognize this format, then it just screens the first frame of the image.
Let's look through the main GIF-files' characteristics:
Color
The color of each image point is defined as an index in color table (palette) stored separately
from the graphic data. Better to say that the image data item for a certain point contains not a
color but address for the color table to define color.

This image consists of 5 pixels with the following indexes: 3, 1, 1, 0 and 2, that point to the
color table defining the RGB-value for these indexes.
Depending on the image coloration the amount of the colors in the color palette may vary from 2
to 256. The color indexes in a shorter color palette will take less volume respectively - 1 bit
for 2 colors, 5 bits for 32, 8 - for 256. The original colors, for some reason missing in the
color palette, may be substituted with the closest available color, or be emulated with the
closest colors bitmap diffusion. The size of the color palette and the number of its colors are
choice of a user - the appearance and neatness of the image is his own case.
The color palette depth has a great influence on the destination file size. The reduction of the
color depth of a GIF-file leads to the reduction of its size and the loading speed increasing.
Diffusion
Diffusion allows creating a different colors blend or a missing color mapping by mixing different
color pixels. Diffusion together with the depth of the color palette influences the GIF-file size.
The picture shows how to imitate purple, using just red and blue.

The pixel mixing takes place only where it is necessary, thus the needed effect is provided.
There may appear spot and stripes, making the image sharpless and artefactial when blending: the
Web-designer should carefully use "safe" color palette containing 216 colors that is used both in
Macintosh and Windows systems. If the GIF-image, being screened in the 8-bit system, contains a
color missing in available color palette, the blending is going to take place.
The diffusion increases the file size, but very often it is the only way to more or less adequate
original color palette screening after the reduction. In other words the diffusion allows to a
greater extent to cut the depth of the GIF-file color palette, thus providing its "lightening".
Compression
The GIF-format uses the same compression algorithms as ordinary archive programs (ZIP, for example),
that's why no data loss happens during writing and reading GIF-images. But unlike archivers,
GIF-files are packed and unpacked automatically. GIF-format uses LZW-compression (after
Lempel-Ziv-Walsh) that allows to effectively compress files, that contain a good amount of
homogeneous fill (logos, inscriptions, schemes).
The GIF-files compression algorithm calculates the number of the equally colored points following
sequentially in horizontal, and stores the reference for the number and color of those points,
but not the each point reference. Nevertheless the compression algorithm for the pattern is not
going to be effective, because every next point is different.
When creating an image one should take into consideration the following features of the LZW-compression.
The graphic data compression degree in GIF-format depends not just the data's repeatability and
predictability (the monochrome image comes with less size, than confusedly "noised"), but also on
the direction of the image, because the image scanning goes line-by-line. The picture shows the
number of bit in GIF-files of the 100x100-pixel image in comparison.

Interlacement
There are two different types of data storage inside the GIF-file. One of them is to store the
image lines one after another from the first to the last one (a noninterlaced storage).
The other is to store the image lines in a certain order (the interlaced storage). For the
second type the storage order is fixed. The lines are stored in 4 passes:
- every 8th line, beginning with the zero;
- every 8th line beginning with the 4th one;
- every 4th line, beginning with the 2nd one;
- every 2nd line, beginning with the 1st one.
The type of an image's storage is a file parameter and is set when creating or editing the file.
Depending on the image storage type the screening comes different - the image is either rolled
out, or it may become shown step-by-step and is enhanced from pass to pass. The file
visuazlization in process of image receiving is typical for the WWW-browsers. This feature
specifies an obvious connection between the storage scheme and the screening process.
Thus a 1/8th of the image is screened in the first pass. Every next step increases the amount of
the lines filled, thus giving an original appearance to the image in four passes. It should be
expected that after the first pass there's going to be seen only every 8th line, while others
will be covered by the background image. Nevertheless, the browsers when screening an image
provide interpolation by pixels with a certain value on each step. This approach allows imaging
the image's outline fast enough. When getting the upcoming data, the separate line's pixels
change their color, thus giving an effect of slow image showing.
This feature is widely used in Internet. First you can see a picture with a coarse resolution,
but when getting new data the quality of an image gets better. The opportunity of the interlaced
step-by-step screening is very popular among Web-designers in Web, where the loading speed is
often a sensitive point.
Transparency
One of the basic advantages of GIF89a format in comparison with other graphic formats is that it
supports transparency. One or more colors may be set transparent in GIF-format, thus staying
hidden in Web-browser and some other applications. This GIF-format feature is widely used in
Internet, especially when there's a necessity to make the Web-page's background be seen through
some parts of the image. The transparency is provided by the additional Alpha-channel, that is
stored together with the file.
Nevertheless the transparency in GIF-file is far from perfect. In certain cases there may appear
a ghost all over the image. For example, smoothing tool is used for creating the blends. In
smoothed images the blend comes really smooth, because the boundaries between the image and the
background are smoothed, and the smoothed colors make a ghost or noise over the image as a result.
The delay period
The delay period is a period of time between the previous frame screening completion and the next
frame output start. Before the next frame output start, the recovery of the screen area, covered
by the image is carried out, in accordance with the mode settings.
The user's entry waiting mode
The user's entry waiting mode enables to interactively manipulate the frame changing while
playback. The delay period and the entry-waiting mode may be set for a certain frame. At the same
time the frame changing is executed when either of the following occurs - the end of the delay
period or the user's entry. Browsers never support this mode.
Commentaries
The commentary addition to the GIF-file is used for the text interpretation of the image and it's
not the part of the image. The size of the commentary is not restricted, but the too large number
of commentaries leads to the file size increasing.
The text lines addition to a file
The text lines addition to a file enables the text visualization in a simple form of a graphic
image fragment. For that the symbol mesh of cells, which is defined by the parameters in this
block of a file, is used. The text data is submitted as fixed-pitch symbols - one symbol per cell,
in the most appropriate font and size. The data is submitted unless the end of data is reached or
the mesh of cells is filled. Browsers never support this mode.
The screen area recovery mode
The screen area recovery mode sets the way of handling the graphic fragment after its screening.
The following modes are defined:
- to do nothing;
- leave as it is, that is the same as to do nothing;
- recover the previous state, that is to fill the screen area with the image
preceded the screening of the current image;
- fill in with the base color (background color or background picture).
The inside GIF-files entries, specific for a certain application
The inside GIF-files entries, specific for a certain application allows to almost infinitely
extend the number of the opportunities upon working with this format. One GIF-file may contain
several different blocks for different applications. It is possible to create a block, ignored by
all applications except one it was intended for. For example the Netscape browser uses such a
block for the image changing loop.
Image Tools Group 2004.